Configuring an HTTP GET Web Service

You can query (HTTP GET) an HTTP server and use the response for various functionality such as routing or saving it, for example, as a session variable in order to use it in SIP message manipulations.

You need to configure a Remote Web Service to represent the HTTP server and a Call Setup Rule to define the search query and the action you want done based on the HTTP response. The following example queries an HTTP server (at IP address 52.7.189.10) using the caller's (source) user name in the server's path /v3/phone. When a response is received from the HTTP server, the device adds the value of the HTTP response body ("Alice") to the From header in the outgoing SIP message.

To configure an HTTP GET operation:
1. Open the Remote Web Services table, and then configure a Remote Web Service for the HTTP server:
'Name': MyHTTP
'Type': General
'Path': v3/phone
'Username': adminuser1
'Password': 1234
2. Open the HTTP Remote Hosts table of the Remote Web Service that you configured in Step 1, and then configure the following:
'Name': MyHTTPHost
'Address': 52.7.189.10
3. Open the Call Setup Rules table, and then configure the following rule:
'Rule Set ID': 1
'Request Type': HTTP GET
'Request Target': MyHTTP
'Request Key': Param.Call.Src.User+'?account_sid=SID&auth_token=TOKEN'
'Action Subject': Param.Call.Src.Name
'Action Type': Modify
'Action Value': HTTP.Response.Body
4. Assign your Call Setup Rule to the relevant SIP Interface, for example.

An example of the HTTP and SIP messages of the above configuration is shown below:

1. Incoming SIP message:
INVITE sip:2000@10.7.7.246;user=phone SIP/2.0 
Via: SIP/2.0/UDP 10.7.2.15;branch=z9hG4bKLRGQTOQHILSSMGAQJQSU 
From: <sip: 15551234567@10.7.2.15;user=phone>;tag=RJFNXMKDOHELDUMEWWGH 
To: <sip:2000@10.7.7.246;user=phone> 
Call-ID: UBBKFKBCXFPESMYOPDTB@10.7.2.15 
CSeq: 1 INVITE 
Contact: <sip:1000@10.7.2.15> 
Supported: em,100rel,timer,replaces 
Allow: REGISTER,OPTIONS,INVITE,ACK,CANCEL,BYE,NOTIFY,PRACK,REFER,INFO,SUBSCRIBE 
User-Agent: Sip Message Generator V1.0.0.5
2. Outgoing HTTP GET:
Header=GET /v3/phone/15551234567?account_sid=SID&auth_token=TOKEN HTTP/1.1 
Content-Type: html/text 
Host: 52.7.189.114 
Connection: keep-alive 
Content-Length: 0 
Cache-Control: no-cache 
User-Agent: 1
3. Incoming HTTP response:
HTTP/1.1 200 OK 
Access-Control-Allow-Origin: * 
Cache-Control: max-age=0 
Content-Type: text/html 
Date: Thu, 07 Dec 2017 14:35:21 GMT 
Server: nginx/1.8.1 
Content-Length: 6 
Connection: keep-alive 

Alice
4. Outgoing SIP message:
INVITE sip:2000@10.7.7.246;user=phone SIP/2.0 
Via: SIP/2.0/UDP 10.7.7.246:5060;branch=z9hG4bKac1693897511 
Max-Forwards: 70 
From: Alice <sip:+15551234567@10.7.2.15;user=phone>;tag=1c1900944531 
To: <sip:2000@10.7.7.246;user=phone> 
Call-ID: 17651812441120101654@10.7.7.246 
CSeq: 1 INVITE 
Contact: <sip:1000@10.7.7.246:5060> 
Supported: em,100rel,timer,replaces,sdp-anat